﻿@{
    Layout = "~/Views/Shared/_FormWhite.cshtml";
}

<div class="wrapper animated fadeInRight">
    <form id="form" class="form-horizontal m">
        <div class="form-group">
            <label class="col-sm-3 control-label">是否需要 新增</label>
            <div class="col-sm-8" id="addStatus" ref="btnAdd"></div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">是否需要 修改</label>
            <div class="col-sm-8" id="editStatus" ref="btnEdit"></div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">是否需要 删除</label>
            <div class="col-sm-8" id="deleteStatus" ref="btnDelete"></div>
        </div>
    </form>
</div>

<script type="text/javascript">
    $(function () {

        var btnAdd = $("#btnAdd", parent.document);
        var btnEdit = $("#btnEdit", parent.document);
        var btnDelete = $("#btnDelete", parent.document);

        $("#addStatus").ysRadioBox({ data: ys.getJson(@Html.Raw(typeof(NeedEnum).EnumToDictionaryString())) });
        $("#editStatus").ysRadioBox({ data: ys.getJson(@Html.Raw(typeof(NeedEnum).EnumToDictionaryString())) });
        $("#deleteStatus").ysRadioBox({ data: ys.getJson(@Html.Raw(typeof(NeedEnum).EnumToDictionaryString())) });

        $('input').on('ifChecked', function (event) {
            var ref = $(this).attr("ref");
            var val = $(this).val();
            if (val == 1) {
                $("#" + ref, parent.document).show();
            }
            else {
                $("#" + ref, parent.document).hide();
            }
        });

        // 设置默认值
        if (btnAdd.is(':hidden')) {
            $("#addStatus").ysRadioBox('setValue',0);
        }
        else {
            $("#addStatus").ysRadioBox('setValue',1);
        }

        if (btnEdit.is(':hidden')) {
            $("#editStatus").ysRadioBox('setValue',0);
        }
        else {
            $("#editStatus").ysRadioBox('setValue',1);
        }

        if (btnDelete.is(':hidden')) {
            $("#deleteStatus").ysRadioBox('setValue',0);
        }
        else {
            $("#deleteStatus").ysRadioBox('setValue',1);
        }

    });


</script>
